package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.mapper.ProductMapper;
import com.zhentao.pojo.Product;
import com.zhentao.service.ProductService;
import com.zhentao.vo.QueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author ls
* @description 针对表【product(商品表)】的数据库操作Service实现
* @createDate 2025-06-30 20:34:14
*/
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService{
    @Autowired
    private ProductMapper productMapper;
    @Override
    public Page<Product> findProductList(QueryParam queryParam) {
        Page<Product> page = new Page<>(queryParam.getCurrent(),queryParam.getSize());
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(queryParam.getProductName()!=null,"product_name",queryParam.getProductName());
        queryWrapper.eq(queryParam.getCategoryId()!=null,"category_id",queryParam.getCategoryId());
        queryWrapper.eq(queryParam.getBrandId()!=null,"brand_id",queryParam.getBrandId());
        queryWrapper.eq(queryParam.getStatus()!=null,"status",queryParam.getStatus());
        productMapper.selectPage(page,queryWrapper);
        return page;
    }
}




